﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using balancescorecard.datasets;
using balancescorecard.datasets.MasterDatasetTableAdapters;
using balancescorecard.utils;

namespace balancescorecard
{
    public partial class _Default : System.Web.UI.Page
    {
       
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
        {
            if(Login1.UserName.Equals("hr")) 
            {
                generateMenu(Roles.HR);
                Login1.DestinationPageUrl = "~/masters/employeeKPILinking.aspx";
               
            }
            else if (Login1.UserName.Equals("emp"))
            {
                generateMenu(Roles.EMPLOYEE);
                Login1.DestinationPageUrl = "~/masters/employeeMaster.aspx";
            }

            e.Authenticated = true;

        }

        private void generateMenu(Roles role)
        {
            switch (role)
            {
                case Roles.EMPLOYEE:
                    Menu[] menuEmp = new Menu[] 
                    {
                       new Menu("Job Master", "~/masters/JobMaster.aspx"),
                    new Menu("Department Master", "~/masters/DeptMaster.aspx"),
                    new Menu("Grade Master", "~/masters/GradeMaster.aspx"),
                    new Menu("Group Master", "~/masters/GroupMaster.aspx"),
                    new Menu("Employee Master", "~/masters/employeeMaster.aspx")

                    };

                    Session[ApplicationConstants.SESSION_ROLE.ToString()] = Roles.EMPLOYEE;
                    Session[ApplicationConstants.MENU_LIST.ToString()] = menuEmp;

                    break;
                case Roles.HR:
                    Menu[] menuHR = new Menu[] 
                    {                      
                        new Menu("Employee Master", "~/masters/employeeMaster.aspx")
                    };

                    Session[ApplicationConstants.SESSION_ROLE.ToString()] = Roles.HR;
                    Session[ApplicationConstants.MENU_LIST.ToString()] = menuHR;

                    break;
                default:
                    break;
            }
        }

        
    }
}
